home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / amiga_plane.s < prev    next >
Text File  |  1998-02-28  |  16KB  |  738 lines

  1.         mc68020
  2.  
  3.         xdef    @R_MakeSpans
  4.         xdef    _R_MakeSpans
  5.  
  6.         xdef    @R_DrawPlanes
  7.         xdef    _R_DrawPlanes
  8.  
  9.         xdef    @R_MapPlane
  10.         xdef    _R_MapPlane
  11.  
  12.         section    text,code
  13.  
  14.         near    a4,-2
  15.  
  16. ;-----------------------------------------------------------------------
  17. ; R_MakeSpans (in r_plane.c) by Arto Huusko <arto.huusko@pp.qnet.fi>
  18.  
  19.         xref    _spanstart
  20. ;;;        xref    @R_MapPlane
  21. ;void
  22. ;__asm R_MakeSpans
  23. ;( register __d2 int x,
  24. ;  register __d3 int t1,
  25. ;  register __d4 int b1,
  26. ;  register __d5 int t2,
  27. ;  register __d6 int b2 );
  28.  
  29.         cnop    0,4
  30. @R_MakeSpans:
  31. _R_MakeSpans:
  32. ;First comments are for the non-__asm version of func prototype
  33.  
  34. ;        movem.l    d2-d7/a2/a3,-(sp)
  35.         movem.l    d3-d7/a2/a3,-(sp)
  36.  
  37. ;        move.l    36(sp),d4    ;(rest of args come in stack) int b1
  38. ;        move.l    d0,d2        ;int x
  39. ;        move.l    40(sp),d5    ;int t2
  40. ;        move.l    d1,d3        ;int t1
  41. ;        move.l    44(sp),d6    ;int b2
  42.  
  43. ;;;         move.l    #_spanstart,a2
  44.         movea.l    _spanstart(a4),a2
  45.         move.l    d2,-(sp)
  46.         subq.l    #1,(sp)    ;x-1, for R_MapPlane (third argument, thus in stack)
  47.  
  48.         ;D2=X D3=T1 D4=B1 D5=T2 D6=B2, (sp)=X-1
  49.  
  50.         ;prepare while(t1 < t2 && t1<=b1)
  51.         ;Calculate just how many times the loop is done, so no need
  52.         ; to compare everytime
  53.         move.l    d5,d7
  54.         sub.l    d3,d7
  55.         ble.b    .rmsl1_Done    ;T1=>T2, therefore loop not done
  56.         subq.l    #1,d7
  57.         move.l    d4,d0
  58.         sub.l    d3,d0
  59. ;If T1>B1 first loop is not done. The same rule also applies to
  60. ;second loop (first: t1<=b1 second: b1>=t1) so we skip both loops.
  61.         bmi.b    .rmsl2_Done
  62.  
  63.         lea    (a2,d3.l*4),a3
  64.         cmp.l    d0,d7    ;Do the loop until the smaller delta is zero
  65.         ;smaller because of AND operation in while statement
  66.         bmi.b    .rms_Loop1
  67.         move.l    d0,d7    ;t1<=b1 effective
  68.  
  69. .rms_Loop1_2:    ;Another loop...
  70.         move.l    (a3)+,d1
  71.         move.l    d3,d0
  72.         jsr    (@R_MapPlane)
  73.         addq.l    #1,d3
  74.         dbf    d7,.rms_Loop1_2
  75.         bra.b    .rmsl2_Done    ;..so we can quickly skip
  76.         ;loop #2. The loop was done with t1<=b1 and in the
  77.         ;end this is not true. Also loop 2 uses the same comparison
  78.         ;it is automatically false thus we can skip it.
  79.  
  80.         cnop    0,4
  81. .rms_Loop1:
  82.         move.l    (a3)+,d1
  83.         move.l    d3,d0
  84.         jsr    (@R_MapPlane)
  85.         addq.l    #1,d3
  86.         dbf    d7,.rms_Loop1
  87.  
  88. .rmsl1_Done:
  89.  
  90.         move.l    d4,d0
  91.         sub.l    d3,d0
  92.         bmi.b    .rmsl2_Done
  93.         move.l    d4,d7
  94.         sub.l    d6,d7
  95.         ble.b    .rmsl2_Done
  96.         subq.l    #1,d7
  97.  
  98.         lea    4(a2,d4.l*4),a3
  99.         cmp.l    d0,d7
  100.         bmi.b    .rms_Loop2
  101.         move.l    d0,d7    ;b1>=t1 effective
  102.  
  103. .rms_Loop2_2:
  104.         move.l    -(a3),d1
  105.         move.l    d4,d0
  106.         jsr    (@R_MapPlane)
  107.         subq.l    #1,d4
  108.         dbf    d7,.rms_Loop2_2
  109.  
  110.         move.l    d3,d7
  111.         sub.l    d5,d7
  112.         bhi.b    .rms_DoL3
  113.  
  114.         bra.w    .rmsl4_Done
  115.  
  116.         cnop    0,4
  117. .rms_Loop2:
  118.         move.l    -(a3),d1
  119.         move.l    d4,d0
  120.         jsr    (@R_MapPlane)
  121.         subq.l    #1,d4
  122.         dbf    d7,.rms_Loop2
  123.  
  124. .rmsl2_Done:
  125.     ;The following copy loops (spanstart[??]=x;) are optimised
  126.     ;by assuming that the loop is executed several (more then four) times
  127.  
  128.         move.l    d3,d7
  129.         sub.l    d5,d7
  130.         ble.b    .rmsl3_Done
  131. .rms_DoL3:
  132.         subq.l    #1,d7
  133.         move.l    d6,d0
  134.         sub.l    d5,d0
  135.         bmi.w    .rmsl4_Done
  136.  
  137.         lea    (a2,d5.l*4),a3
  138.         cmp.l    d0,d7
  139.         bmi.b    .rms_StartLoop3
  140.  
  141.         move.l    d2,(a3)+
  142.         bclr    #0,d0
  143.         beq.b    .rmsl32_Pass1
  144.         move.l    d2,(a3)+
  145. .rmsl32_Pass1:
  146.         bclr    #1,d0
  147.         beq.b    .rmsl32_Pass2
  148.         move.l    d2,(a3)+
  149.         move.l    d2,(a3)+
  150. .rmsl32_Pass2:
  151.         tst.l    d0    
  152.         beq.b    .rmsl4_Done
  153. .rms_Loop3_2:
  154.         move.l    d2,(a3)+
  155.         move.l    d2,(a3)+
  156.         move.l    d2,(a3)+
  157.         move.l    d2,(a3)+
  158.         subq.l    #4,d0
  159.         bgt.b    .rms_Loop3_2
  160.         bra.b    .rmsl4_Done
  161.  
  162.         cnop    0,4
  163.  
  164. .rms_StartLoop3:
  165.         move.l    d2,(a3)+    ;always at least once
  166.  
  167.         bclr    #0,d7
  168.         beq.b    .rmsl3_Pass1
  169.         move.l    d2,(a3)+
  170. .rmsl3_Pass1:
  171.         bclr    #1,d7
  172.         beq.b    .rmsl3_Pass2
  173.         move.l    d2,(a3)+
  174.         move.l    d2,(a3)+
  175. .rmsl3_Pass2:
  176.         tst.l    d7
  177.         beq.b    .rmsl3_Done
  178. .rms_Loop3:
  179.         move.l    d2,(a3)+
  180.         move.l    d2,(a3)+
  181.         move.l    d2,(a3)+
  182.         move.l    d2,(a3)+
  183.         addq.l    #4,d5    ;saves for addq per loop
  184.         subq.l    #4,d7    ;also saves four dbfs, though adds here...
  185.         bgt.b    .rms_Loop3
  186.  
  187. .rmsl3_Done:
  188.  
  189.         move.l    d6,d0
  190.         sub.l    d5,d0
  191.         bmi.b    .rmsl4_Done
  192.         move.l    d6,d7
  193.         sub.l    d4,d7
  194.         ble.b    .rmsl4_Done
  195.         subq.l    #1,d7
  196.  
  197.         lea    4(a2,d6.l*4),a3
  198.         cmp.l    d0,d7
  199.         bmi.b    .rms_StartLoop4
  200.         move.l    d0,d7
  201.  
  202. .rms_StartLoop4:
  203.         move.l    d2,-(a3)    ;always at least once
  204.  
  205.         bclr    #0,d7
  206.         beq.b    .rmsl4_Pass1
  207.         move.l    d2,-(a3)
  208. .rmsl4_Pass1:
  209.         bclr    #1,d7
  210.         beq.b    .rmsl4_Pass2
  211.         move.l    d2,-(a3)
  212.         move.l    d2,-(a3)
  213. .rmsl4_Pass2:
  214.         tst.l    d7
  215.         beq.b    .rmsl4_Done
  216. .rms_Loop4:
  217.         move.l    d2,-(a3)
  218.         move.l    d2,-(a3)
  219.         move.l    d2,-(a3)
  220.         move.l    d2,-(a3)
  221.         subq.l    #4,d7
  222.         bgt.b    .rms_Loop4
  223.  
  224. .rmsl4_Done:
  225.         addq.l    #4,sp
  226.         movem.l    (sp)+,d3-d7/a2/a3
  227. ;        movem.l    (sp)+,d2-d7/a2/a3
  228.         rts
  229.  
  230.  
  231. ;void R_MakeSpans(int x, int t1, int b1, int t2, int b2)
  232. ;{
  233. ;
  234. ;    while (t1 < t2 && t1<=b1)
  235. ;    {
  236. ;        R_MapPlane (t1,spanstart[t1],x-1);
  237. ;        t1++;
  238. ;    }
  239. ;    while (b1 > b2 && b1>=t1)
  240. ;    {
  241. ;        R_MapPlane (b1,spanstart[b1],x-1);
  242. ;        b1--;
  243. ;    }
  244. ;
  245. ;    while (t2 < t1 && t2<=b2)
  246. ;    {
  247. ;        spanstart[t2] = x;
  248. ;        t2++;
  249. ;    }
  250. ;    while (b2 > b1 && b2>=t2)
  251. ;    {
  252. ;        spanstart[b2] = x;
  253. ;        b2--;
  254. ;    }
  255. ;}
  256.  
  257. ;-----------------------------------------------------------------------
  258. ; R_DrawPlanes (in r_plane.c) by Arto Huusko <arto.huusko@pp.qnet.fi>
  259.  
  260. ;        STRUCTURE    visplane,0
  261. ;
  262. ;         LONG    height
  263. ;         LONG    picnum
  264. ;         LONG    lightlevel
  265. ;         LONG    minx
  266. ;         LONG    maxx
  267. ;         PTR    top
  268. ;         PTR    bottom
  269. ;
  270. ;        LABEL    visplane_size
  271.  
  272. height        equ    0        ; fixed
  273. picnum        equ    4        ; int
  274. lightlevel    equ    8        ; int
  275. minx        equ    12        ; int
  276. maxx        equ    16        ; int
  277. top        equ    20        ; unsigned short* ([-1..SCREENWIDTH])
  278. bottom        equ    24        ; unsigned short* ([-1..SCREENWIDTH])
  279. visplane_size    equ    28
  280.  
  281.         xref    _visplanes        ; FAR visplane_t[]
  282.         xref    _skyflatnum        ; int
  283.         xref    _flattranslation    ; int*
  284.         xref    _firstflat        ; int
  285.         xref    _viewz            ; fixed_t
  286.         xref    _planeheight        ; fixed_t
  287.         xref    _zlight    ; FAR lighttable_t *[LIGHTLEVELS][MAXLIGHTZ]
  288.         xref    _planezlight        ; lighttable_t**
  289.         xref    _extralight        ; int
  290.         xref    _lastvisplane        ; visplane_t*
  291. ;;;        xref    _pspriteiscale        ; fixed_t
  292.         xref    _pspriteiscale2        ; fixed_t
  293.         xref    _detailshift        ; int
  294.         xref    _skytexturemid        ; int
  295.         xref    _viewangle        ; angle_t
  296.         xref    _skytexture        ; int
  297.         xref    _ds_source
  298.         xref    _colormaps
  299.         xref    _dc_colormap
  300.         xref    _dc_iscale
  301.         xref    _dc_texturemid
  302.         xref    _xtoviewangle        ; angle_t *
  303.         xref    _dc_x
  304.         xref    _dc_yl
  305.         xref    _dc_yh
  306.         xref    _dc_source
  307.         xref    _colfunc
  308.  
  309.         xref    @W_CacheLumpNum
  310.         xref    @Z_ChangeTag2
  311.         xref    @R_GetColumn
  312.  
  313.  
  314.         cnop    0,4
  315. @R_DrawPlanes:
  316. _R_DrawPlanes:
  317.         movem.l    d2-d7/a2/a3/a5/a6,-(sp)
  318.  
  319.         move.l    #_visplanes,a2
  320.  
  321. .rd_Loop:
  322.         move.l    minx(a2),d2
  323.         move.l    maxx(a2),d3        ;These ones are used later, too
  324.         cmp.l    d2,d3
  325.         bmi.w    .rd_Next        ;minx>maxx -> next loop
  326.  
  327. ;;;        move.l    a2,a3
  328. ;;;        add.l    d2,a3        ; a3 -> pl + minx
  329. ;;;        move.l    a3,a5        ; a5 -> pl + minx
  330. ;;;        add.l    #top,a3        ; a3 -> pl + minx + top
  331. ;;;        add.l    #bottom-1,a5    ; a5 -> pl + minx + bottom - 1
  332.  
  333.         movea.l    top(a2),a3
  334.         lea    (a3,d2.l*2),a3    ; a3 -> pl->top[minx]
  335.         movea.l    bottom(a2),a5
  336.         lea    -2(a5,d2.l*2),a5 ; a5 -> pl->bottom[minx-1]
  337.  
  338.         move.l    picnum(a2),d1    ; used if not sky...
  339.         cmp.l    _skyflatnum(a4),d1
  340.         beq.w    .rdl_Sky
  341.  
  342.         move.l    _flattranslation(a4),a0
  343.         move.l    _firstflat(a4),d0
  344.         add.l    (a0,d1.l*4),d0    ; D1 contains picnum, A0 array of ints
  345.         moveq    #1,d1        ; PU_STATIC
  346.         jsr    (@W_CacheLumpNum)
  347.         move.l    d0,_ds_source(a4)
  348.  
  349.         move.l    height(a2),d0
  350.         sub.l    _viewz(a4),d0
  351.         bpl.b    .rdl_HP        ; These two lines are equal to
  352.         neg.l    d0        ; abs() or iabs(). Branch if =>0, otherwise switch sign
  353. .rdl_HP:
  354.         move.l    d0,_planeheight(a4)
  355.         move.l    lightlevel(a2),d0
  356.         lsr.l    #4,d0    ;LIGHTSEGSHIFT
  357.         move.l    #_zlight,_planezlight(a4)
  358.         add.l    _extralight(a4),d0
  359.  
  360.         cmp.l    #0,d0
  361.         bmi.b    .rdl_LightDone    ; lightlevel 0, no need to change _planezlight anymore
  362.         cmp.l    #16,d0        ; 16=LIGHTLEVELS
  363.         bmi.b    .rdl_LightOK
  364.         add.l    #7680,_planezlight(a4)    ;15<<9 ((15<<7)*4)
  365.         bra.b    .rdl_LightDone
  366. .rdl_LightOK:
  367.         lsl.l    #8,d0
  368.         add.l    d0,d0
  369.         add.l    d0,_planezlight(a4)
  370.  
  371. .rdl_LightDone:
  372. ;;;        move.b    #$FF,top+1(a2,d3.l)    ;D3=maxx, top+1 ->top[maxx+1]
  373. ;;;        move.b    #$FF,-(a3)
  374.         movea.l    top(a2),a0
  375.         move.w    #$FFFF,2(a0,d3.l*2)    ;D3=maxx, top+1 ->top[maxx+1]
  376.         move.w    #$FFFF,-(a3)
  377.  
  378.         ;x=pl->minx=d2
  379.         move.l    d3,d7
  380.         sub.l    d2,d7
  381.         addq.l    #1,d7    ;d7 = x<=stop
  382.  
  383.         moveq    #0,d3
  384.         moveq    #0,d4
  385.         moveq    #0,d5
  386.         moveq    #0,d6
  387.  
  388. .rdl_MSLoop:
  389. ;;;        move.b    (a3)+,d3    ; bumps to top[x] at the same time!
  390. ;;;        move.b    (a3),d5
  391. ;;;        move.b    (a5)+,d4
  392. ;;;        move.b    (a5),d6
  393.         move.w    (a3)+,d3    ; bumps to top[x] at the same time!
  394.         move.w    (a3),d5
  395.         move.w    (a5)+,d4
  396.         move.w    (a5),d6
  397.         jsr    (@R_MakeSpans)    ; passes d2/d3/d4/d5/d6
  398.         addq.l    #1,d2
  399.         dbf    d7,.rdl_MSLoop
  400.  
  401.         move.l    _ds_source(a4),a0
  402.         moveq    #101,d0        ; PU_STATIC
  403.         jsr    (@Z_ChangeTag2)
  404.  
  405. .rd_Next:
  406.         add.l    #visplane_size,a2
  407.         cmp.l    _lastvisplane(a4),a2    ; pl<lastvisplane
  408.         bmi.w    .rd_Loop
  409.  
  410.         movem.l    (sp)+,d2-d7/a2/a3/a5/a6
  411.  
  412.         rts
  413.  
  414.         cnop    0,4
  415. .rdl_Sky:
  416. ;;;         move.l    _pspriteiscale(a4),d0
  417. ;;;         move.l    _detailshift(a4),d1
  418. ;;;         asr.l    d1,d0
  419.         move.l    _pspriteiscale2(a4),d0
  420.         move.l    _colormaps(a4),_dc_colormap(a4)
  421.         move.l    d0,_dc_iscale(a4)
  422.         move.l    _skytexturemid(a4),_dc_texturemid(a4)
  423.  
  424.         sub.l    d2,d3    ; maxx-minx == maxx-x, how many till x>maxx
  425.         moveq    #0,d5
  426.         moveq    #0,d6
  427. ;;;        lea    _xtoviewangle(a4),a6
  428.         movea.l    _xtoviewangle(a4),a6
  429.         lea    (a6,d2.l*4),a6    ; a6 -> xtoviewangle[minx]
  430.         moveq    #22,d7        ; ANGLETOSKYSHIFT
  431.         move.l    d2,_dc_x(a4)    ; dc_x = minx
  432. ;;;        addq.l    #1,a5
  433.         addq.l    #2,a5        ; a5 -> pl->bottom[minx]
  434.  
  435. .rdl_SkyLoop:
  436. ;;;        move.b    (a3)+,d5
  437. ;;;        move.b    (a5)+,d6
  438.         move.w    (a3)+,d5    ; dc_yl = pl->top[x]
  439.         move.w    (a5)+,d6    ; dc_yh = pl->bottom[x]
  440.         move.l    d5,_dc_yl(a4)
  441.         move.l    d6,_dc_yh(a4)
  442.  
  443.         move.l    (a6)+,d1    ; To keep values consistent if not drawn
  444.  
  445. ; the next 2 lines may be unnecessary --- but who knows?
  446.         cmp.l    d5,d6
  447.         bmi.b    .rdlsl_Next    ; needless? I think so...
  448.  
  449.         add.l    _viewangle(a4),d1    ; viewangle + xtoviewangle[x]
  450.         move.l    _skytexture(a4),d0
  451.         asr.l    d7,d1        ; angle
  452.         jsr    (@R_GetColumn)    ; R_GetColumn(skytexture,angle)
  453.         move.l    d0,_dc_source(a4)
  454.         move.l    _colfunc(a4),a0
  455.         jsr    (a0)
  456.  
  457. .rdlsl_Next:
  458.         addq.l    #1,_dc_x(a4)    ; dc_x = x
  459.         dbf    d3,.rdl_SkyLoop
  460.         bra.b    .rd_Next
  461.  
  462.  
  463. ; void R_DrawPlanes (void)
  464. ; {
  465. ;     visplane_t*        pl;
  466. ;     int            light;
  467. ;     int            x;
  468. ;     int            stop;
  469. ;     int            angle;
  470. ;     for (pl = visplanes ; pl < lastvisplane ; pl++)
  471. ;     {
  472. ;     if (pl->minx > pl->maxx)
  473. ;         continue;
  474. ;     
  475. ;     // sky flat
  476. ;     if (pl->picnum == skyflatnum)
  477. ;     {
  478. ;         dc_iscale = pspriteiscale2/*>>detailshift*/;
  479. ;         
  480. ;         // Sky is allways drawn full bright,
  481. ;         //  i.e. colormaps[0] is used.
  482. ;         // Because of this hack, sky is not affected
  483. ;         //  by INVUL inverse mapping.
  484. ;         dc_colormap = colormaps;
  485. ;         dc_texturemid = skytexturemid;
  486. ;         for (x=pl->minx ; x <= pl->maxx ; x++)
  487. ;         {
  488. ;             dc_yl = pl->top[x];
  489. ;             dc_yh = pl->bottom[x];
  490. ;             if (dc_yl <= dc_yh)
  491. ;             {
  492. ;                 angle = (viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
  493. ;                 dc_x = x;
  494. ;                 dc_source = R_GetColumn(skytexture, angle);
  495. ;                 colfunc ();
  496. ;             }
  497. ;         }
  498. ;         continue;
  499. ;     }
  500. ;     
  501. ;     // regular flat
  502. ;     ds_source = W_CacheLumpNum(firstflat +
  503. ;                    flattranslation[pl->picnum],
  504. ;                    PU_STATIC);
  505. ;     
  506. ;     planeheight = iabs(pl->height-viewz);
  507. ;     light = (pl->lightlevel >> LIGHTSEGSHIFT)+extralight;
  508. ;     if (light >= LIGHTLEVELS)
  509. ;         light = LIGHTLEVELS-1;
  510. ;     if (light < 0)
  511. ;         light = 0;
  512. ;     planezlight = zlight[light];
  513. ;    //pl->top[pl->maxx+1] = 0xff;
  514. ;    //pl->top[pl->minx-1] = 0xff;
  515. ;    pl->top[pl->maxx+1] = 0xffff;
  516. ;    pl->top[pl->minx-1] = 0xffff;
  517. ;         
  518. ;     stop = pl->maxx + 1;
  519. ;     for (x=pl->minx ; x<= stop ; x++)
  520. ;     {
  521. ;         R_MakeSpans(x,pl->top[x-1],
  522. ;             pl->bottom[x-1],
  523. ;             pl->top[x],
  524. ;             pl->bottom[x]);
  525. ;     }
  526. ;     
  527. ;     Z_ChangeTag (ds_source, PU_CACHE);
  528. ;     }
  529. ; }
  530.  
  531. ;-----------------------------------------------------------------------
  532. ; R_MapPlane (in r_plane.c) by Arto Huusko <arto.huusko@pp.qnet.fi>
  533.  
  534.         xref    _cachedheight    ;fixed_t*
  535.         xref    _cacheddistance    ;fixed_t*
  536.         xref    _yslope        ;fixed_t*
  537.         xref    _cachedxstep    ;fixed_t*
  538.         xref    _cachedystep    ;fixed_t*
  539.         xref    _basexscale    ;fixed_t
  540.         xref    _baseyscale    ;fixed_t
  541.         xref    _distscale    ;fixed_t*
  542.         xref    _viewx        ;fixed_t
  543.         xref    _viewy        ;fixed_t
  544.         xref    _finecosine    ;fixed_t*
  545.         xref    _finesine    ;FAR int []
  546.         xref    _fixedcolormap    ;lighttable_t*
  547.         xref    _ds_xstep
  548.         xref    _ds_ystep
  549.         xref    _ds_x1
  550.         xref    _ds_x2
  551.         xref    _ds_y
  552.         xref    _ds_xfrac
  553.         xref    _ds_yfrac
  554.         xref    _ds_colormap
  555.  
  556.         xref    _spanfunc
  557.         xref    _FixedMul
  558.  
  559. MAXLIGHTZ    equ    128
  560. LIGHTZSHIFT    equ    20
  561. ANGLETOFINESHIFT    equ    19
  562.  
  563. ;void
  564. ;R_MapPlane
  565. ;( int        y,
  566. ;  int        x1,
  567. ;  int        x2 )
  568.  
  569.         cnop    0,4
  570. @R_MapPlane:
  571. _R_MapPlane:
  572.         movem.l    d3/d4/d7,-(sp)
  573.  
  574.         move.l    d0,d3        ;Y
  575.         move.l    d1,d4        ;X1
  576.  
  577.         move.l    _FixedMul(a4),a1    ;Prepare function. amiga_fixed.s does not use A1!
  578.         move.l    _planeheight(a4),d0    ;ready for cache...
  579. ;;;        move.l    #_cachedheight,a0
  580.         movea.l    _cachedheight(a4),a0
  581.         cmp.l    (a0,d3.l*4),d0
  582.         beq.b    .rm_If2                ;ah, we are cached!
  583.  
  584.         move.l    d0,(a0,d3.l*4)
  585. ;;;        move.l    #_yslope,a0
  586.         movea.l    _yslope(a4),a0
  587.         move.l    (a0,d3.l*4),d1
  588.         jsr    (a1)
  589.         move.l    d0,d7            ;save distance
  590. ;;;        move.l    #_cacheddistance,a0
  591.         movea.l    _cacheddistance(a4),a0
  592.         move.l    d0,(a0,d3.l*4)
  593.         move.l    _basexscale(a4),d1
  594.         jsr    (a1)
  595.         move.l    d0,_ds_xstep(a4)
  596. ;;;        move.l    #_cachedxstep,a0
  597.         movea.l    _cachedxstep(a4),a0
  598.         move.l    d0,(a0,d3.l*4)
  599.         move.l    _baseyscale(a4),d1
  600.         move.l    d7,d0
  601.         jsr    (a1)
  602.         move.l    d0,_ds_ystep(a4)
  603. ;;;        move.l    #_cachedystep,a0
  604.         movea.l    _cachedystep(a4),a0
  605.         move.l    d0,(a0,d3.l*4)
  606.         bra.b    .rm_1Done
  607.  
  608. .rm_If2:
  609. ;;;         move.l    #_cacheddistance,a0
  610.         movea.l    _cacheddistance(a4),a0
  611.         move.l    (a0,d3.l*4),d7
  612. ;;;        move.l    #_cachedxstep,a0
  613.         movea.l    _cachedxstep(a4),a0
  614.         move.l    (a0,d3.l*4),_ds_xstep(a4)
  615. ;;;        move.l    #_cachedystep,a0
  616.         movea.l    _cachedystep(a4),a0
  617.         move.l    (a0,d3.l*4),_ds_ystep(a4)
  618.  
  619. .rm_1Done:
  620.         move.l    d3,_ds_y(a4)
  621.         move.l    d4,_ds_x1(a4)
  622.  
  623.         move.l    d7,d0
  624. ;;;        move.l    #_distscale,a0
  625.         movea.l    _distscale(a4),a0
  626.         move.l    (a0,d4.l*4),d1
  627.         jsr    (a1)
  628.         move.l    d0,d3    ;Y not needed anymore
  629.  
  630. ;;;        lea    _xtoviewangle(a4),a0
  631.         movea.l    _xtoviewangle(a4),a0
  632.         move.l    (a0,d4.l*4),d4        ;x1 not needed anymore
  633.         add.l    _viewangle(a4),d4
  634.         moveq    #ANGLETOFINESHIFT,d1
  635.         lsr.l    d1,d4
  636.         move.l    _finecosine(a4),a0
  637.         move.l    (a0,d4.l*4),d0
  638.         move.l    d3,d1
  639.         jsr    (a1)
  640.         move.l    _viewx(a4),_ds_xfrac(a4)
  641.         add.l    d0,_ds_xfrac(a4)
  642.         move.l    #_finesine,a0
  643.         move.l    (a0,d4.l*4),d0
  644.         move.l    d3,d1
  645.         jsr    (a1)
  646.         move.l    _viewy(a4),d1
  647.         neg.l    d1
  648.         move.l    d1,_ds_yfrac(a4)
  649.         sub.l    d0,_ds_yfrac(a4)
  650.  
  651.         move.l    _fixedcolormap(a4),d0
  652.         bne.b    .rm_FixedCMAP
  653.  
  654.         moveq    #LIGHTZSHIFT,d0
  655.         lsr.l    d0,d7
  656.         cmp.l    #MAXLIGHTZ,d7
  657.         bmi.b    .rm_D7OK
  658.         move.l    #MAXLIGHTZ-1,d7
  659. .rm_D7OK:
  660.         move.l    _planezlight(a4),a0
  661.         move.l    (a0,d7.l*4),_ds_colormap(a4)
  662.  
  663. .rm_CMAPDone:
  664.         move.l    16(sp),_ds_x2(a4)
  665.  
  666.         move.l    _spanfunc(a4),a0
  667.         jsr    (a0)
  668.  
  669.         movem.l    (sp)+,d3/d4/d7
  670.  
  671.         rts
  672.         cnop    0,4
  673. .rm_FixedCMAP:
  674.         move.l    d0,_ds_colormap(a4)
  675.         bra.b    .rm_CMAPDone
  676.  
  677. ;void
  678. ;R_MapPlane
  679. ;( int        y,
  680. ;  int        x1,
  681. ;  int        x2 )
  682. ;{
  683. ;    angle_t    angle;
  684. ;    fixed_t    distance;
  685. ;    fixed_t    length;
  686. ;    unsigned    index;
  687. ;
  688. ;    if (planeheight != cachedheight[y])
  689. ;    {
  690. ;    cachedheight[y] = planeheight;
  691. ;    distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
  692. ;    ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale);
  693. ;    ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale);
  694. ;    }
  695. ;    else
  696. ;    {
  697. ;    distance = cacheddistance[y];
  698. ;    ds_xstep = cachedxstep[y];
  699. ;    ds_ystep = cachedystep[y];
  700. ;    }
  701. ;
  702. ;    length = FixedMul (distance,distscale[x1]);
  703. ;    angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
  704. ;    ds_xfrac = viewx + FixedMul(finecosine[angle], length);
  705. ;    ds_yfrac = -viewy - FixedMul(finesine[angle], length);
  706. ;
  707. ;    if (fixedcolormap)
  708. ;    ds_colormap = fixedcolormap;
  709. ;    else
  710. ;    {
  711. ;    index = distance >> LIGHTZSHIFT;
  712. ;    
  713. ;    if (index >= MAXLIGHTZ )
  714. ;        index = MAXLIGHTZ-1;
  715. ;
  716. ;    ds_colormap = planezlight[index];
  717. ;    }
  718. ;    
  719. ;    ds_y = y;
  720. ;    ds_x1 = x1;
  721. ;    ds_x2 = x2;
  722. ;
  723. ;    // high or low detail
  724. ;    spanfunc ();    
  725. ;}
  726.  
  727. ;-----------------------------------------------------------------------
  728.  
  729.         end
  730.